package ua.kpi_java_training.evgeniygusar.module2;

import java.util.Random;

public class Victim extends Fish {
    enum Destination {left,right,up,down};

    /**
     * Move of Victim to the random destination
     */
    public void Moving() {
        Random rnd = new Random(System.currentTimeMillis());
        int numOfVictimDestination = rnd.nextInt(4);
        Destination victimDestination = Destination.values()[numOfVictimDestination];
        doMoving(victimDestination);
    }

    /**
     * Change x or y coordinate of Victim due to destination, that generated at random in previous method
     * @param dest - destination
     */
    public void doMoving(Destination dest) {
        switch (dest) {
            case right:
                if(x!=X_BORDER)
                    x++;
            case left:
                if(x!=1)
                    x--;
            case up:
                if(y!=1)
                    y--;
            case down:
                if(y!=Y_BORDER)
                    y++;
        }
    }
}
